package com.foreknow.util;

import javax.swing.*;
import javax.swing.table.DefaultTableModel;

public class DefaulTableModelUtil {
    private DefaultTableModel tableModel = new DefaultTableModel();
    private static DefaulTableModelUtil defaulTableModelUtil = null;

    private DefaulTableModelUtil(){
    }

    public static DefaulTableModelUtil getInstance() {
        if (defaulTableModelUtil == null) {
            defaulTableModelUtil = new DefaulTableModelUtil();
        }
        return defaulTableModelUtil;
    }

    //创建表格
    public JTable createJtable(Object[][] data,String[] column) {
        tableModel.setDataVector(data,column);
        JTable jTable = new JTable(tableModel);
        return jTable;
    }

    //更新表格
    public void updateJtable(Object[][] data,String[] column) {
        tableModel.setDataVector(data,column);
    }

}